//https://www.luogu.com.cn/problem/P1873
//二分答案
//以0为下界，最大树高为上界二分答案
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[1000005];
int main(){
    ll n,m;
    
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%lld",a+i);
        //if(a[i]>r) r=a[i];
    }
    sort(a+1,a+n+1);
    ll l=0,r=a[n];
    while(l<r){
        ll mid=(l+r>>1)+1;
        int i=upper_bound(a+1,a+n+1,mid)-a;
        ll temp=0;
        for(;i<=n;i++){
            
            temp+=a[i]-mid;
        }
        if(temp<m){
            r=mid-1;
        }
        else{
            l=mid;
        }
    }
    printf("%lld",l);
    return 0;
}